package ontime

import org.apache.flink.streaming.api.scala._

/**
  * @author dinghao 
  * @create 2021-07-28 9:47 
  * @message
  */
object CountWindowsflink {
  def main(args: Array[String]): Unit = { //nc ip
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val socketData = env.socketTextStream(args(0), 9999)
    socketData.flatMap(_.split(" "))
      .map((_, 1)).keyBy(_._1)
      .countWindow(3)
      .reduce((a, b) => (a._1, a._2 + b._2))
      .print()
    env.execute("CountWindowsflink")
  }
}
